import { stockApi } from "@/api/index.js";
import { mapState } from "vuex";
import gridManager from '_c/common/gridManager';
import { filterWrap } from '@/components/index';
export default {
    components: { filterWrap, gridManager },
    name: 'formulaLibrary',
    data() {
        return {
            dataList: [
                {
                    data1: '110218A',
                    data2: 'CF2021117A',
                    data3: 'CF2021117A',
                    data4: '79.41',
                    data5: '若依',
                    data6: '2023-07-18',
                    data7: '否',
                    data8: '审核成功',
                },
                {
                    data1: '110218A',
                    data2: 'CF2021117A',
                    data3: 'CF2021117A',
                    data4: '79.41',
                    data5: '若依',
                    data6: '2023-07-18',
                    data7: '否',
                    data8: '审核成功',
                },
                {
                    data1: '110218A',
                    data2: 'CF2021117A',
                    data3: 'CF2021117A',
                    data4: '79.41',
                    data5: '若依',
                    data6: '2023-07-18',
                    data7: '否',
                    data8: '审核成功',
                },
                {
                    data1: '110218A',
                    data2: 'CF2021117A',
                    data3: 'CF2021117A',
                    data4: '79.41',
                    data5: '若依',
                    data6: '2023-07-18',
                    data7: '否',
                    data8: '审核成功',
                },
                {
                    data1: '110218A',
                    data2: 'CF2021117A',
                    data3: 'CF2021117A',
                    data4: '79.41',
                    data5: '若依',
                    data6: '2023-07-18',
                    data7: '否',
                    data8: '审核成功',
                },
            ],
            query: {
                pageIndex: 1,
                pageSize: 20
            },
            total: 5,
            gridOption: {
                gridManagerName: 'formulaLibrary',
                skinClassName: 'gridManagerTable',
                firstLoading: false,
                supportCheckbox: false,
                supportMenu: false,
                i18n: "zh-cn",
                disableBorder: true,
                disableLine: true,
                supportDrag: false,
                supportAdjust: false,
                maxHeight: '100%',
                height: 'auto',
                lineHeight: '54px',
                columnData: [
                    {
                        key: 'order',
                        text: '序号',
                        align: 'center',
                        template: (value, row, index) => {
                            return `<span>${(this.query.pageIndex - 1) * this.query.pageSize + index + 1}</span>`;  // 基于行索引生成序号‌:ml-citation{ref="1,2" data="citationList"}
                        }
                    },
                    { key: 'data1', text: '配方编号', align: 'center', width: '110px' },
                    { key: 'data2', text: '中文名称', align: 'center', width: '150px', template: (cell) => { return `<el-tooltip class="item" effect="dark" content="${cell}" placement="right"><span class="tooltip">${cell}</span></el-tooltip>` } },
                    { key: 'data3', text: '英文名称', align: 'center', width: '150px', template: (cell) => { return `<el-tooltip class="item" effect="dark" content="${cell}" placement="right"><span class="tooltip">${cell}</span></el-tooltip>` } },
                    { key: 'data4', text: '成本价', align: 'center', width: '150px', template: (cell) => { return `<el-tooltip class="item" effect="dark" content="${cell}" placement="right"><span class="tooltip">${cell}</span></el-tooltip>` } },
                    { key: 'data5', text: '添加人姓名', align: 'center' },
                    { key: 'data6', text: '添加时间', align: 'center' },
                    { key: 'data7', text: '是否弃用', align: 'center' },
                    { key: 'data8', text: '审核状态', align: 'center' },
                    {
                        key: 'action', text: '操作', align: 'center', width: '180px',
                        template: (action, row) => {
                            return `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">查看详情</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">操作记录</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">弃用</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">复制</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">ifra判定(国内)</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">ifra判定(出口)</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">致敏判定</span>`
                            + `<span class="plugin-action" data-id="${row.id}" @click="editRow(${row})">打印</span>`
                        }
                    }
                ],
                ajaxData: { data: [] },
            }
        }
    },
    computed: {
        ...mapState(['userInfo']),
    },

    mounted() {
        this.ProductCommission();
    },
    methods: {
        ProductCommission() {                               // 获取商品业绩数据
            stockApi.ProductCommission(this.queryObj).then(res => {
                this.$gridManager.setAjaxData('formulaLibrary', {
                    data: this.dataList
                });
            });
            this.total = 5;
        },
        handleShowPrivateRoomTips() {
            this.showPrivateRoomTips = true;
            this.$refs.refPrivateRoomTips && this.$refs.refPrivateRoomTips.show();
        },
        handleSubmit(number, type) {            // 提交引导显示次数
            this.activeMask = -1;
            let sv_novice_count = type === 'add' ? this.$store.state.maskEntity.count + number : number;
            stockApi.OperateNoviceGuide({ id: this.$store.state.maskEntity.id, sv_novice_count: sv_novice_count }).then(res => {
                this.$store.commit('updateMaskEntity', { id: -1, count: 0 });
            });
        },
    }
};